import axiosInstance from "../utils/axios.ts";
import type {DepartmentDTO, DepartmentVO} from "../types";
import {type MaybeRef, unref} from "vue";


export const getDepartments = (companyId: MaybeRef<number | undefined>) => {
  return axiosInstance.post<any,DepartmentDTO[]>("/department/getList", undefined, {
    params: {
      id: unref(companyId)
    }
  })
}

export const insertDepartment = (department: DepartmentVO) => {
  return axiosInstance.post<any,boolean>("/department/save", undefined, {
    params: {
      id: department.gs_id,
      name: department.name
    }
  })
}

export const deleteDepartment = (id: number) => {
  return axiosInstance.delete<any,boolean>("/department/delete", {
    params: {
      id: id
    }
  })
}